/** ###################################################################
**     Filename  : Communication.c
**     Project   : parking
**     Processor : MC9S12XS128MAL
**     Compiler  : CodeWarrior HCS12X C Compiler
**     Date/Time : 2013-3-2, 10:48
**     Contents  :
**         User source code
**
** ###################################################################*/

/* MODULE Communication */


#include "Communication.h"


volatile U8 ASpEventBuffer = 0;

void ASIrqHandler(void){
	U8 c;
    if(AS_RecvChar(&c) == ERR_OK) {
		ASpEventBuffer = c;
	}
	return;	
	
}

U8 ASReadEvent(void)
{
	U8 result = ASpEventBuffer;
	ASpEventBuffer = 0;
	return result;
}
U8 ASReadEventStill(void){
    U8 result = ASpEventBuffer;
    return result;    
}

void ASSendByte(U8 data)
{
	while (AS_SendChar(data) != ERR_OK) { /* spin */ }
	return;
}

void ASSendData(U8 *data, U16 size)
{
	U16 snd;
	
	while (size != 0) {
		snd = 0;
		(void)AS_SendBlock(data, size, (unsigned int*) &snd);
		data += snd;
		size -= snd;
	}
	return;
}

/* END Communication */
